//
// Created by vcq on 21/2/25.
//

#pragma once
#include "dbng.hpp"
struct _syllabus_teachgoal {
    int id;
    int _teachgoal_id;
    int _syllabus_id;
    string note;
};
REFLECTION(_syllabus_teachgoal, id, _teachgoal_id,_syllabus_id,note)

json mgetSyllabusTeachGoal(basic_string_view<char> id,basic_string_view<char> _teachgoal_id,basic_string_view<char> _syllabus_id) {
    string sql = "select * from `_teach_goal` where 1=1 ";
    if (!id.empty()) {
        sql += " and id =";
        sql += id;
    }
    if (!_teachgoal_id.empty()) {
        sql += " and _teachgoal_id =";
        sql += _teachgoal_id;
    }
    if (!_syllabus_id.empty()) {
        sql += " and _syllabus_id =";
        sql += _syllabus_id;
    }
    Dao dao;
    nlohmann::json article_list,ret,item;
    auto v = dao.query<_syllabus_teachgoal>(sql);
    for (auto &o : v) {
        item["id"] = o.id;
        item["_teachgoal_id"] = o._teachgoal_id;
        item["_syllabus_id"] = o._syllabus_id;
        item["note"] = o.note;
        article_list.push_back(item);
    }
    ret["code"] = 0;
    ret["count"] = article_list.size();
    ret["data"] = article_list;
    return ret;
}